package main.Game;

/**
 * 需要使用Client作为媒介
 * 玩家类
 * 由player生成SendInfor，Joiner负责发送，获取所需要的信息，返回给player
 * @author svitter
 */
public class Player{

    public String   name;            	/** 玩家姓名 */
    public boolean  lose;				/** 是否认输 */
    public int 	point;				/** 分数 */
    
    private boolean turn;				/** 是否轮到回合 */
    public int      uid;				/** 玩家的特定编号，依据服务器分配的给定 */

    public BoardGroup      board;      		/** 自有牌 */
    SendInfor 		si;              	/** 发送的信息 */

    public Player(String name, int uid) {
        this.name = name;
        this.board = new BoardGroup();
        this.uid = uid;
        lose = false;
    }
    
    public Player(String name) {
        // use file to edit
        this.name = name;
        this.board = new BoardGroup();
        this.uid = -1;
        lose = false;
    }
    
    public Player(int uid) {
    	this.uid = uid;
    	this.name = "Player";
    	this.board = new BoardGroup();
    	lose = false;
    }
    
    public void setUid(int uid) {
    	this.uid = uid;
    	si = new SendInfor(this.uid);
    }

    /**
     * 显示自己的牌（自己的角度）
     * @return BoardGroup
     * @throws CloneNotSupportedException 
     */
    public BoardGroup board(boolean isSelf) throws CloneNotSupportedException {
    	if(isSelf) {
    		return board;
    	} else {
    		return board.hideVersion();
    	}
    }

    /**
     * 依据objid显示他人的牌
     * @param uid
     */
    public SendInfor showOther(int objid) {
    	if(this.uid == -1)
    		return null;
    	si = new SendInfor(this.uid);
    	si.show(objid);
    	return si;
    }
    
    /**
     * TODO 显示User
     */
    public Player showUser() {
    	return this;
    }
    
    /**
     * 猜测别人的牌
     * @param uid
     */
    public void guessOther(int uid) {

    }
    
    /**
     * 添加新牌
     * @param b
     */
    public void add(Board b) {
    	board.add(b);
    }
    
}
